﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using IDAL;

namespace DAL
{
    /// <summary>
    /// 攻略评论
    /// </summary>
    public class D_Comment : IComment
    {
        WishDayEntities _es;
        public D_Comment()
        {
            _es = new WishDayEntities();
        }
        public void Add(Comment obj)
        {
            _es.Comment.Add(obj);
            _es.SaveChanges();
        }

        public void Delete(int id)
        {
            _es.Comment.Remove(_es.Comment.Find(id));
            _es.SaveChanges();
        }

        public Comment FindById(int id)
        {
            return _es.Comment.Find(id);
        }

        public List<Comment> GetAll()
        {
            return _es.Comment.ToList();
        }

        public void Update(int id, Comment obj)
        {
            var data = _es.Comment.Find(id);
            data.Reviewer = obj.Reviewer;
            data.Descriptors = obj.Descriptors;
            data.Cimage = obj.Cimage;
            data.CreateTime = obj.CreateTime;
            data.StrategID = obj.StrategID;
            data.UserID = obj.UserID;
            _es.SaveChanges();
        }
    }
}
